using System;
using System.Text.RegularExpressions;

namespace DynamicConfigurationManager.ConfigMapAttributes
{
    /// <summary>
    /// ConfigPathRegEx compares the attribute value to the fully qualified path of the current configuration file.
    /// </summary>
    internal class ConfigPathRegEx : IConfigMapAttribute
    {
        public bool Execute( string configMapAttribute )
        {
            var currentConfigPath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
            LogHelper.Append( "ConfigPathRegEx: matching to {0}", currentConfigPath );
            var re = new Regex( configMapAttribute, RegexOptions.IgnoreCase );
            return re.IsMatch( currentConfigPath );
        }
    }
}